package cn.cqie.attendance.manager.controller;

import cn.cqie.attendance.common.util.Page;
import cn.cqie.attendance.common.util.PageBean;
import cn.cqie.attendance.manager.pojo.*;
import cn.cqie.attendance.manager.service.AdminCourseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 697
 * @date 2021/7/2 14:35
 */
@RestController
@Api(tags = "管理员端-课程管理模块")
@RequestMapping("/admin/course")
public class AdminCourseController {

    @Autowired AdminCourseService adminCourseService;

    /**
     *查询课程信息 可组合模糊查询
     * @param adminCourseSerch
     * @param pageSize 每页的数量
     * @param pageNum 当前页
     * @return
     */
    @GetMapping("/queryAllCourseInfo")
    @ApiOperation("查询课程信息 可组合模糊查询")
    public PageBean<AdminCourse> queryAllCourseInfo(AdminCourseSerch adminCourseSerch, Integer pageSize, Integer pageNum){
        return adminCourseService.queryAllCourseInfo(adminCourseSerch,pageSize,pageNum);
    }


    /**
     * 根据ID查询课程信息
     * @param courseId　id
     * @return
     */
    @GetMapping("/queryCourseInfoById")
    @ApiOperation("根据ID查询课程信息")
    public Page<AdminCourse> queryCourseInfoById(Integer courseId){
        return adminCourseService.queryCourseInfoById(courseId);
    }


    /**
     * 查询所有老师 用于选择实训老师
     * @return
     */
    @GetMapping("/queryChooseTrainerTeacher")
    @ApiOperation("查询所有老师 用于选择实训老师")
    public Page<AdminTeacher> queryChooseTrainerTeacher(){
        return adminCourseService.queryChooseTrainerTeacher();
    }


    /**
     * 新增课程信息
     * @param adminCourse
     * @param listTrainTeacher
     * @return
     */
    @PostMapping("/addCourseInfo")
    @ApiOperation("新增课程信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "signInTime", value = "签到时间(16:25:36)", required = true),
            @ApiImplicitParam(name = "signOutTime", value = "签退时间(16:25:36)", required = true),
            @ApiImplicitParam(name = "classRoom", value = "上课教室(6教302)", required = true),
            @ApiImplicitParam(name = "courseName", value = "课程名(语文课)", required = true),
            @ApiImplicitParam(name = "courseTime", value = "课程时间(2021-09-06)", required = true),
            @ApiImplicitParam(name = "responseTeacher", value = "责任老师id(1)", required = true),
            @ApiImplicitParam(name = "remark", value = "课程备注(带电脑)", required = false)})
    public Page addCourseInfo(AdminCourse adminCourse, @RequestBody List<AdminTrainTeacherCourse> listTrainTeacher){
        return adminCourseService.addCourseInfo(adminCourse,listTrainTeacher);
    }


    /**
     * 根据id修改课程信息
     * @param adminCourse 课程
     * @param listTrainTeacher 课程实训老师
     * @return
     */
    @PostMapping("/updateCourseById")
    @ApiOperation("根据id修改课程信息")
    public Page updateCourseById(AdminCourse adminCourse, @RequestBody List<AdminTrainTeacherCourse> listTrainTeacher){
        return adminCourseService.updateCourseById(adminCourse,listTrainTeacher);
    }


    /**
     * 课程选择学生
     * @param adminCourseTemp
     * @return
     */
    @PostMapping("/addStudentToCourse")
    @ApiOperation("课程选择学生")
    public Page addStudentToCourse(@RequestBody AdminCourseTemp adminCourseTemp){
        return adminCourseService.addStudentToCourse(
                adminCourseTemp.getListGroupId(),
                adminCourseTemp.getCourseId(),
                adminCourseTemp.getListStudentId());
    }


    /**
     * 根据学生id查询详情
     * @param studentId
     * @return
     */
    @GetMapping("/queryStudentByStudentId")
    @ApiOperation("根据学生id查询详情")
    public Page queryStudentByStudentId(Integer studentId){
        return adminCourseService.queryStudentByStudentId(studentId);
    }


    /**
     * 查询分组下面的所有学生
     * @param listGroupId 分组id
     * @return
     */
    @PostMapping("/queryStudentByAllGroupId")
    @ApiOperation("查询分组下面的所有学生")
    public Page queryStudentByAllGroupId(@RequestBody List<Integer> listGroupId){
       return adminCourseService.queryStudentByAllGroupId(listGroupId);
    }


    /**
     * 根据课程ＩＤ删除课程信息
     * @param courseId
     * @return
     */
    @GetMapping("/deleteCourseById")
    @ApiOperation("根据课程id删除课程信息")
    public Page deleteCourseById(Integer courseId){
        return adminCourseService.deleteCourseById(courseId);

    }


    /**
     * 复制课程信息
     * @param adminCourse 课程
     * @param listTrainTeacher 实训老师
     * @return
     */
    @PostMapping("/CopyCourseInfoById")
    @ApiOperation("复制课程信息")
    public Page CopyCourseInfoById(AdminCourse adminCourse, @RequestBody List<AdminTrainTeacherCourse> listTrainTeacher,Integer courseId){
        return adminCourseService.CopyCourseInfoById(adminCourse,listTrainTeacher,courseId);
    }


//    /**
//     * 根据id查询该班级下的学生 用于复制课程时复制学生 自己调用
//     * @param courseId
//     * @return
//     */
//    @PostMapping("/queryStudentByCourseId")
//    @ApiOperation("查询学生根据班级id ")
//    public Page queryStudentByCourseId(Integer courseId){
//        return adminCourseService.queryStudentByCourseId(courseId);
//    }


}
